package com.sopaths.taglib;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class ScriptTag extends SimpleTagSupport {

	private String relativePath;

	@Override
	public void doTag() throws JspException, IOException {
		PageContext context = (PageContext) getJspContext();
		HttpServletRequest request = (HttpServletRequest) context.getRequest();
		String contextPath = request.getContextPath();
		String html = "<script type=\"text/javascript\" src=\"" + contextPath + "/resources/js/" + relativePath + "\"></script>";
		context.getOut().println(html);
	}

	public String getRelativePath() {
		return relativePath;
	}

	public void setRelativePath(String relativePath) {
		this.relativePath = relativePath;
	}
}
